var express = require('express'),
    app = express(),
    path = require('path'),
    bodyParser = require('body-parser'),
    multer = require('multer'),
    session = require('express-session');
app.use(session({
    secret:'secret',
    resave:true,
    saveUninitialized:false,
    cookie:{
        maxAge:1000*60*10
    }
}));
app.set('view engine','ejs');
app.set('views',path.join(__dirname,'views'));
app.use(bodyParser.urlencoded({extended:false}));
app.use(bodyParser.json());
app.use(express.static(path.join(__dirname,'./public')))
app.use(multer());
app.use(function(req,res,next){
    res.locals.user = req.session.user;
    var err = req.session.error;
    res.locals.message = '';
    if (err) res.locals.message = '<div style = "margin-bottom:20px;color:red;">' + err + '</div>';
    next();
});
app.get('/',function(req,res){
    res.render('index',{
        title:'众知商城',
        name:'name',
        mouth:'mouth',
        day:'day',
        syn:'syn',
        num:'num',
        percent:'percent'
    })
})
app.get('/web_info',function(req,res){
    res.render('web_info',{
        title:'众知商城',
        name:'name',
        mouth:'mouth',
        day:'day',
        syn:'syn',
        num:'num',
        percent:'percent',
        time:'time'
    })
})
app.get('/goods_lists',function(req,res){
    res.render('goods_lists',{
        title:'众知商城',
        name:'name',
        mouth:'mouth',
        day:'day',
        syn:'syn',
        num:'num',
        percent:'percent'
    })
})
app.get('/points_goods',function(req,res){
    res.render('points_goods',{
        title:'众知商城',
        name:'name',
        mouth:'mouth',
        day:'day',
        syn:'syn',
        num:'num',
        percent:'percent'
    })
})
app.get('/self_category',function(req,res){
    res.render('self_category',{
        title:'众知商城',
        name:'name',
        mouth:'mouth',
        day:'day',
        syn:'syn',
        num:'num',
        percent:'percent'
    })
})
app.get('/self_category',function(req,res){
    res.render('self_category',{
        title:'众知商城',
        name:'name',
        mouth:'mouth',
        day:'day',
        syn:'syn',
        num:'num',
        percent:'percent'
    })
})
app.get('/sto-loc_set',function(req,res){
    res.render('sto-loc_set',{
        title:'众知商城',
        name:'name',
        mouth:'mouth',
        day:'day',
        syn:'syn',
        num:'num',
        percent:'percent'
    })
})
app.get('/repertory_lists',function(req,res){
    res.render('repertory_lists',{
        title:'众知商城',
        name:'name',
        mouth:'mouth',
        day:'day',
        syn:'syn',
        num:'num',
        percent:'percent'
    })
})
app.get('/repertory_log',function(req,res){
    res.render('repertory_log',{
        title:'众知商城',
        name:'name',
        mouth:'mouth',
        day:'day',
        syn:'syn',
        num:'num',
        percent:'percent'
    })
})
app.get('/repertory_scan',function(req,res){
    res.render('repertory_scan',{
        title:'众知商城',
        name:'name',
        mouth:'mouth',
        day:'day',
        syn:'syn',
        num:'num',
        percent:'percent'
    })
})
app.get('/unpaied_lists',function(req,res){
    res.render('unpaied_lists',{
        title:'众知商城',
        name:'name',
        mouth:'mouth',
        day:'day',
        syn:'syn',
        num:'num',
        percent:'percent'
    })
})
app.get('/unsent_lists',function(req,res){
    res.render('unsent_lists',{
        title:'众知商城',
        name:'name',
        mouth:'mouth',
        day:'day',
        syn:'syn',
        num:'num',
        percent:'percent'
    })
})
app.get('/unreceived_lists',function(req,res){
    res.render('unreceived_lists',{
        title:'众知商城',
        name:'name',
        mouth:'mouth',
        day:'day',
        syn:'syn',
        num:'num',
        percent:'percent'
    })
})
app.get('/received_lists',function(req,res){
    res.render('received_lists',{
        title:'众知商城',
        name:'name',
        mouth:'mouth',
        day:'day',
        syn:'syn',
        num:'num',
        percent:'percent'
    })
})
app.get('/returned_lists',function(req,res){
    res.render('returned_lists',{
        title:'众知商城',
        name:'name',
        mouth:'mouth',
        day:'day',
        syn:'syn',
        num:'num',
        percent:'percent'
    })
})
app.get('/closed_lists',function(req,res){
    res.render('closed_lists',{
        title:'众知商城',
        name:'name',
        mouth:'mouth',
        day:'day',
        syn:'syn',
        num:'num',
        percent:'percent'
    })
})
app.get('/compl_lists',function(req,res){
    res.render('compl_lists',{
        title:'众知商城',
        name:'name',
        mouth:'mouth',
        day:'day',
        syn:'syn',
        num:'num',
        percent:'percent'
    })
})
app.get('/refuseback_lists',function(req,res){
    res.render('refuseback_lists',{
        title:'众知商城',
        name:'name',
        mouth:'mouth',
        day:'day',
        syn:'syn',
        num:'num',
        percent:'percent'
    })
})
app.get('/outstorage_lists',function(req,res){
    res.render('outstorage_lists',{
        title:'众知商城',
        name:'name',
        mouth:'mouth',
        day:'day',
        syn:'syn',
        num:'num',
        percent:'percent'
    })
})
app.get('/pre_unpaied_lists',function(req,res){
    res.render('pre_unpaied_lists',{
        title:'众知商城',
        name:'name',
        mouth:'mouth',
        day:'day',
        syn:'syn',
        num:'num',
        percent:'percent'
    })
})
app.get('/pre_pay_lists',function(req,res){
    res.render('pre_pay_lists',{
        title:'众知商城',
        name:'name',
        mouth:'mouth',
        day:'day',
        syn:'syn',
        num:'num',
        percent:'percent'
    })
})
app.get('/pre_paied_lists',function(req,res){
    res.render('pre_paied_lists',{
        title:'众知商城',
        name:'name',
        mouth:'mouth',
        day:'day',
        syn:'syn',
        num:'num',
        percent:'percent'
    })
})
app.get('/pre_unreceived_lists',function(req,res){
    res.render('pre_unreceived_lists',{
        title:'众知商城',
        name:'name',
        mouth:'mouth',
        day:'day',
        syn:'syn',
        num:'num',
        percent:'percent'
    })
})
app.get('/pre_received_lists',function(req,res){
    res.render('pre_received_lists',{
        title:'众知商城',
        name:'name',
        mouth:'mouth',
        day:'day',
        syn:'syn',
        num:'num',
        percent:'percent'
    })
})
app.get('/pre_compl_lists',function(req,res){
    res.render('pre_compl_lists',{
        title:'众知商城',
        name:'name',
        mouth:'mouth',
        day:'day',
        syn:'syn',
        num:'num',
        percent:'percent'
    })
})
app.get('/pre_closed_lists',function(req,res){
    res.render('pre_closed_lists',{
        title:'众知商城',
        name:'name',
        mouth:'mouth',
        day:'day',
        syn:'syn',
        num:'num',
        percent:'percent'
    })
})
app.get('/logistics_fee',function(req,res){
    res.render('logistics_fee',{
        title:'众知商城',
        name:'name',
        mouth:'mouth',
        day:'day',
        syn:'syn',
        num:'num',
        percent:'percent'
    })
})
app.get('/logistics_set',function(req,res){
    res.render('logistics_fee',{
        title:'众知商城',
        name:'name',
        mouth:'mouth',
        day:'day',
        syn:'syn',
        num:'num',
        percent:'percent'
    })
})
app.get('/zz_login',function(req,res){
    res.render('zz_login',{
        title:'登录'
    })
})
app.post('/zz_login',function(req,res){
    var use = {
        username:'admin',
        password:'admin'
    }
    if (req.body.username == use.username && req.body.password == use.password){
        req.session.user = user;
        res.send(200);
    } else {
        req.session.error = '用户名或密码不正确';
        res.send('123123');
    }
})
app.get('/zz_register',function(req,res){
    res.render('zz_register',{
        title:'注册'
    })
})
app.get('/addProduct1',function(req,res){
    res.render('addProduct1',{
        title:'众知商城',
        name:'name',
        mouth:'mouth',
        day:'day',
        syn:'syn',
        num:'num',
        percent:'percent'
    })
})
app.get('/addProduct2',function(req,res){
    res.render('addProduct2',{
        title:'众知商城',
        name:'name',
        mouth:'mouth',
        day:'day',
        syn:'syn',
        num:'num',
        percent:'percent'
    })
})
app.get('/addProduct3',function(req,res){
    res.render('addProduct3',{
        title:'众知商城',
        name:'name',
        mouth:'mouth',
        day:'day',
        syn:'syn',
        num:'num',
        percent:'percent'
    })
})
app.get('/addProduct4',function(req,res){
    res.render('addProduct4',{
        title:'众知商城',
        name:'name',
        mouth:'mouth',
        day:'day',
        syn:'syn',
        num:'num',
        percent:'percent'
    })
})
app.get('/addProduct5',function(req,res){
    res.render('addProduct5',{
        title:'众知商城',
        name:'name',
        mouth:'mouth',
        day:'day',
        syn:'syn',
        num:'num',
        percent:'percent'
    })
})
app.listen(3000);
console.log('123');